test: refactor test-fs-write-file-sync.js
This commit reduces shared state by introducing scopes and block scoped variables. It also makes the monkey patching used by the test more robust.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines