This has a *lot* of logic for a mock function. Can it be simplified at all? Can you delegate to the real function in certain places, so you don't need to duplicate the logic?