Refactoring
Add tests