Improved various tests to be more compatible on Windows (#2886)