Revert "Refs #5533 try threads with fitting moved inside function"

This reverts commit 787a9cba192bf1e8c386ebfdd73ade3c8102ff04.
Merge branch 'feature/5533_IntegratePeaksMD_segfault_new' into develop