[test] Fix error message for C++ failures (#2193)