Added some tests, refactored some code
Added some tests