Fix loop context length calculation for iterators. Fixes #244

This resulted in wrong values for revindex and revindex0
while looping over an iterator.
Merge pull request #315 from lazka/fix-iter-length

Fix loop context length calculation for iterators. Fixes #244