fix unittest, refactor Node.writeFile