Tests: Better error reporting and some fixes