Test: try really harder to show tests correctly (#37809)
By serializing both tests and backtraces (as strings), and trying to
ensure other parts are not going to mess them up along the way.
Hopefully this should improve error message reporting reliability in our
Base runtests.