Uses StringIO instead of trying to mock out all file handle method