adding test coverage - refactor following dependency injection pattern to allow effective mocking of dependencies for testing