bit of refactoring, increasing test coverage