Add failing iteration test.
Avoid accidental calling of functions in iteration block. Closes #986
Merge pull request #987 from puckey/master

Avoid accidental calling of functions during iteration