If it appears that the defendant is entitled to a return of the goods, he shall have judgment and a writ of return accordingly, with damages for the taking and costs. If the plaintiff claims the property replevied as security for a debt, his claim shall be discharged by payment or tender thereof, with interest and costs; and judgment shall be for a return without costs, unless his title has become absolute by a legal foreclosure.