Replace generators with two for loops.

The generator comprehensions were incorrectly written and when rewritten
correctly ended up being slower and less readable than two for loops.
Add renaming tests.