A surety suing for contribution must first account for all money or other things received from the principal to indemnify him against loss; and, if he has paid the entire debt, he may compel his cosurety to transfer to him any mortgage or other security taken from the principal for the protection of such cosurety, by relieving him of all liability for contribution.