Avoiding race conditions in test-io by moving IO functions in the fs.stat callback

This is a partial fix for https://github.com/oaeproject/Hilary/issues/549.
Not really sure yet why the signature test is failing.