When there is a lien on an undivided interest or estate of any of the parties, if partition is made such lien is thenceforth a charge only on the share allotted to such party; but such share shall first be charged with its just proportion of the costs and charges of the partition, in preference to such lien.