Added some tests and a little bit of general clean-up