More fixes with closures and test cases