Improve test_threaded_with use of local