Added tests and general cleanup
t