Improve error checks in test_case.cpp