fix tests and improve mocking to be more robust