fix mock

should not assign mock.exit() if mock is not defined.