I read the summary of these cases, based on what I understand, even though both contracts were based on illegalities, they were still enforceable because they were done under extreme circumstances.
The motive for going into contract was to save the family's well-being. Had the circumstances been favorable for both parties, they would not have agreed on such contract.