Replaced lambdas and fixed some errors in py2and3 tests