tests pass after refactoring