replaced dict.iteritems with dict.items for python 3 compatibility

Tests fail, because dictionary items are not sorted.