(3) Where any party to the contract has, by reason of anything done by any other party thereto in, or for the purpose of, the performance of the contract, obtained a valuable benefit (other than a payment of money to which the last foregoing paragraph applies) before the time of discharge, there shall be recoverable from him or her by the said other party such sum (if any), not exceeding the value of the said benefit to the party obtaining it, as the Court considers just, having regard to all the circumstances of the case and, in particular,—
-
(a) the amount of any expenses incurred before the time of discharge by the benefited party in, or for the purpose of, the performance of the contract, including any sums paid or payable by him or her to any other party in pursuance of the contract and retained or recoverable by that party under the last foregoing paragraph, and
-
(b) the effect, in relation to the said benefit, of the circumstances giving rise to the frustration of the contract.