This fixes the test failures on Windows from the new tests, and includes test fixes as well as the module fix.
Based on the testing ideas in a patch written by Greg Malcolm.