Fixing a few problems with the tests on windows

On Windows file operations sometimes return different error codes then on
other systems, so I extended the test cases. I am not sure whether my
changes represent the most elegant way to do this.