Less hackish implementation of wrap_transaction