There shall be no recovery of possession pursuant to this chapter pending final disposition of the plaintiff's action if the court finds that the requirements of the second paragraph have been met. The court after hearing the case may require the tenant or occupant claiming under this section to pay to the clerk of the court the fair value of the use and occupation of the premises less the amount awarded the tenant or occupant for any claim under this section, or to make a deposit with the clerk of such amount or such installments thereof from time to time as the court may direct, for the occupation of the premises. In determining said fair value, the court shall consider any evidence relative to the effect of any conditions claimed upon the use and occupation of residential premises. Such funds may be expended for the repair of the premises by such persons as the court after a hearing may direct, including if appropriate a receiver appointed as provided in section one hundred and twenty-seven H of chapter one hundred and eleven. When all of the conditions found by the court have been corrected, the court shall direct that the balance of funds, if any, remaining with the clerk be paid to the landlord. Any tenant or occupant intending to invoke the provisions of this section may, after commencement of an action under this chapter by the landlord, voluntarily deposit with the clerk any amount for rent or for use and occupation which may be in dispute, and such payments shall be held by the clerk subject to the provisions of this paragraph.