Use temporary-named cursors for fold to support nesting

This also suppresses the exception produced by CLOSE in a
failed transaction.
testFold: test nested folds and exception handling