Refactor how the connection is mocked