Fix and test usecase for conditionally defined variable inside the loop
and other cleanups and more docs