Small optimization - .items() call replaced with .iteritems()
Code refinement
Small simplification in test