This constitutes the whole fix, tbh - the other changes are just to get the tests to run on windows (which was required for me to validate the fix)