Add extra tests, improve error reporting