A trespasser, if the trespass was casual and involuntary, may, before an action is commenced, tender the damages and, upon action brought, disclaim title and allege the tender and that the trespass was casual and involuntary; and if it is found that the allegations are true and if he has deposited with the court the amount of his tender at the time of filing his answer and the damages assessed are not more than the amount tendered, he shall recover costs. Such tender may, subject to the same provisions, be made after the action has been commenced with like effect, if it covers the costs to the time of tender.
Mass. Gen. Laws ch. 242, § 8