In Python 3 OrderedDict.keys() are not indexable

We could always cast counts.keys() to a list, from the dictionary view they
are but a more efficient way of doing this is to simply pop the items from
our result list as we traverse the returned iterable dictionary view.

(fixes test issues where Python complains that 'KeysView' object is not indexable)