fixed thread stuff and made tests cleaner