Fix testThread race