Refactoring, improving test coverage