The payment or tender of payment of the whole amount due on a contract for the payment of money after it is due and payable and before action is commenced shall, if pleaded, have the same effect as if made at the time provided in the contract. Such payment or tender may also be made after action has been commenced if made at least four days prior to the date by which the answer must be filed, with costs to the time of payment or tender. The tender last mentioned may be made to the plaintiff or to his attorney in the action, and, if not accepted, the defendant may avail himself of the tender in defense in like manner as if made before the commencement of the action, bringing into court the amount so tendered.
Mass. Gen. Laws ch. 232A, § 1