rewrite using mocking tests