cleaned up a little
added more tests for errors