fix windows builds
Address cpearce's review
Test case for bug 792263
Do a bit more debugging