Fix some issues found by PVS studio
Use threads only with 2 or more testcases