Refactored code, added a test
Moved code to code directory