Capture more information when reporting test failures

See the commit messages for more info.