Added tests
Refactored