Improve support for valgrind tests.