Fix tests when valgrind is missing

As per #499.