Fixed memory errors found during Valgrind profiling.
Allow setting num_iterations in testparser.