Add refactored code to tests, all passing