All improvement districts in this state are directed to make refunds of amounts received by a district for the purchase of lands acquired by it by foreclosure of the district's lien for taxes, or assessments levied by it upon lands located therein, when the title shall fail and the sale by which the district has acquired the lands is cancelled and set aside by a court of competent jurisdiction.