Add a few more tests and fix error reporting bugs