Spy on fs.writeFileSync in test
Move spy above use