Upon any indictment for embezzlement, it is a sufficient defense that the property was appropriated openly and avowedly, and under a claim of title preferred in good faith, even though such claim is untenable. But this provision does not excuse the unlawful retention of the property of another to offset or pay demands held against him.
Ca. Pen. Code § 511