[#1384] Fix test broken due to sorted change

* Fix the test broken because it expects results from sorted.
* Correct the PEP8 change in related controller.