Improve test_threaded_with use of local
Merge branch 'thread-safe-test' into dev