[1.6.x] Fixed ordering related test failure

Also PEP8 + python_2_unicode_compatible cleanup done.

Backport of 263b873599 from master