Added a couple of tests
Cleaned up the code