Section 18. If, in an action against a bank for money on deposit therewith, it appears that the same fund is claimed by another party than the plaintiff, whether by the husband or wife of the plaintiff, or otherwise, the court in which such action is pending, on the petition of the bank and on such notice to the plaintiff and to such claimants as the court considers proper, may order the proceedings to be amended by making such claimants defendants thereto, and thereupon the rights and interests of the several parties in and to said funds shall be heard and determined. Such deposits may remain with the bank until final judgment and shall be paid as the court orders, or may be paid into court to await final judgment, and when so paid into court, the action shall be discontinued as to such bank and its liability for such deposit shall cease. The taxable costs of the bank in such actions shall be in the discretion of the court and may be charged upon the fund.