Index-value for-in loop refactoring of big create_for_in_loop_function.

1. Everyvere rename key to index. It makes more sense.
2. Move big parts of code to sub-functions. Decided what using of parameters of master function from sub-function is ok.
3. In case of error free resources at end of function.

TODO: more tests for errors. Check memory leaks.
Index-value for-in loop: CurrentKey modificator.

TODO:
+ more test, specially for errors.
+ add new error messages