Added some tests and tweaked some things