Section 40. If a dam has been so erected or maintained or if a person has at his own expense made, kept open or repaired any ditches or drains for the improvement or cultivation of such tract of land, any owner or lessee of a like tract, who uses such dam, ditches or drains or who by more remote means receives benefit thereby for the flowing, irrigating or draining of such last mentioned tract, shall pay to the person who has erected or maintained such dam or incurred such expense his proportionate part thereof, which shall be determined by the aldermen of the city or the selectmen of the town and certified to such owner or lessee. Any person aggrieved by such determination may within three months after notice thereof appeal therefrom to the superior court for the county where the dam, ditches or drains are situated, and shall be entitled to a jury trial; but before taking his appeal he shall give one month's notice, in writing, to the aldermen or selectmen of his intention so to appeal, and shall therein specify particularly his objections to the determination, to which specification he shall be confined upon the hearing by jury. If such owner or lessee fails to pay to the person entitled such proportionate part as finally determined, within said three months if there is no appeal, otherwise within seven days after final determination, he shall pay double the amount so determined with all expenses arising from such failure; and such person may recover the same in contract in his own name. But no covenants or agreements by or between the owners or lessees of such land shall be affected by this section.