Rearrange code and separate file system tasks to be able to stub them.