Fix loop context length calculation for iterators. Fixes #244

This resulted in wrong values for revindex and revindex0
while looping over an iterator.