Update testSafeWrite(): setUp, tearDown and refactoring.