Refactor dict comprehension which doesn't exist in python 2.6.

passes test suite for all out supported python versions