bug fix in ensure-transactions; refactor with-logical-transactions