[tests] Fix execution order of iterator methods.

We were testing iterators following a broken assumption about the
order in which the Zend engine executes the various methods during
the iteration.