Section 158. The selectmen of towns having a population of five thousand or less may license suitable persons to keep more than four horses in specified buildings or places within their respective towns, and may revoke such licenses at pleasure. The fee for such licenses shall be established by said selectmen, but in no event shall any such fee be greater than twenty dollars. Whoever, not being licensed as aforesaid, occupies or uses a building or place for a stable for more than four horses shall forfeit not more than fifty dollars for every month he so occupies or uses such building or place, and in like proportion for a shorter time. The superior court may restrain the erection, occupancy or use of stables contrary to this section or section one hundred and fifty-five or one hundred and fifty-six.