Add valgrind support in test scripts