With slight modification, test 7 passes with no valgrind issues.