unit tests passing after more refactoring