Function mocking for unit testing