more refactoring after failing tests