Enhance unit test a bit to show more info if it is failing in CI
Adjust to cleanly run on Windows by freeing resources correctly