Added some actual unit tests and fixed up some OOP problems