Fix bug in lambda, which falls into infinite loop.
Add simple tests for lambda.