Replace instances of dict.iteritems() with dict.items() and made sure a test creates a directory if it doesn't already exist