Added tests and final cleanup