tests refactored and passing