refactored, better tests, all green