Refactored mock to recursively process values