Fix hanging on tests failing

Tee hanging when `go test` exit with non-zero code.
Fixes #5672