write test for writing file on directory and directory on file