added better errors and some more tests