Better error checks in tests