added more tests and some basic error handling