test based refactor