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