Fix unittest in core.thread

This unittest crashed/asserted for me this morning: it tries to detach a thread that might not have been initialized properly yet. In my case, the thread was not yet added to the thread list (this is done in the new thread itself), but remove is called by thread_detachInstance.

This could also be considered a bug in the synchronization on the thread list, but it is dubious to detach a thread that isn't fully initialized anyway. You could have created a OS thread in that case to start with.