added some more unit tests and fixed a bug
added more verbose error messages