Fix some six changes

In light of #1891, I grepped for instances of `list(six.iterkeys(d))`, and ended up finding one bug and another place that could be made more efficient.