fix various bugs in run test file
add early termination feature to valgrind runner