Added tests for CreateFile

Also added `scope_exit` by @yuriks, which is exceedingly helpful for cleanup in tests.