test_checkdir.c: try to make it pass on windows

also fix memory-leak on failing tests.