refactoring finished; all test compile