tests: Fix memleak in run-threaded