In the recent case of Alatriste v. Cesar's Exterior Designs, Inc., the case actually addressed the issue of the homeowner actually knowing that the general is unlicensed. The court concluded that the statute is very clear--it didn't matter that the homeowner knew that the general was unlicensed, the general contractor still had to disgorge all payments (including costs) of the job.
It strikes me that in previous case law, there was discussion of the legislative intent to protect consumers from unlicensed contractors, and that before even evaluating whether the contractor could make a showing of unjust enrichment the courts would evaluate whether the general was licensed at the time of negotiating the contract with the homeowners. The obvious reasoning being the homeowner should not be misled by the general's licensed status at the time of contracting. However, if the homeowner knows the contractor is not licensed in California, negotiates a lower price as a result, getting "handyman" rates, then should the homeowner retain the right to then seek disgorgement when the relationship goes south? Seems inequitable, and perhaps an unintended gap in the legislation.