The tender last mentioned may be made either to the plaintiff or his attorney in the suit, and the defendant may avail himself of it in defense, in like manner as if it had been made before the commencement of the action, bringing into court, if the tender is not accepted, the amount so tendered for costs as well as for the debt or damages.