Refactoring and test add