Added tests and cleaned up some things.