foreach block and some fixes to make it work. Also define-block and tests.