Add some test assertions to make sure that errors return nil, errmsg
Simplify error handling