Handle indexVariable in foreach, this fixes #14
Because any foreach based on iter will be wrapped
as while, this commit should work.
Add test for #759, apply @zhaihj's fix. Closes #759