Fix scope when a lambda is executed.
Added some more tests.