Task queue on rolledback transactions

We have an unitests which calls the confirm transition of a purchase. This button adds a tasks to the queue but it is not processed untill the end of the transaction.

As the transaction is rolled back on each test, the following errors are raised on the console:

CRITICAL:trytond.worker:task "1" failed
Traceback (most recent call last):
  File "/home/pokoli/.virtualenvs/ingsys/lib/python3.7/site-packages/trytond/worker.py", line 106, in run_task
  File "/home/pokoli/.virtualenvs/ingsys/lib/python3.7/site-packages/trytond/ir/queue.py", line 145, in run
    Model = Pool().get(self.data['model'])
  File "/home/pokoli/.virtualenvs/ingsys/lib/python3.7/site-packages/trytond/model/fields/field.py", line 298, in __get__
    return inst.__getattr__(self.name)
  File "/home/pokoli/.virtualenvs/ingsys/lib/python3.7/site-packages/trytond/model/modelstorage.py", line 1417, in __getattr__
    read_data = self.read(list(ids), list(ffields.keys()))
  File "/home/pokoli/.virtualenvs/ingsys/lib/python3.7/site-packages/trytond/model/modelsql.py", line 757, in read
    cls.raise_user_error('read_error', cls.__name__)
  File "/home/pokoli/.virtualenvs/ingsys/lib/python3.7/site-packages/trytond/error.py", line 74, in raise_user_error
    raise UserError(error)
trytond.exceptions.UserError: ('UserError', ("You try to read records that don't exist anymore.\n(Document type: ir.queue)", ''))

Is this the expected behaviour or we should clear the transaction tasks when the transaction is rolled back?

For the unittest there is not a big issue: tests passes, only error message is shown on the console.

The problem is that we do not know from which transaction the task comes from. So we do not know up to which tasks the rollback should clear.
So we would need to store the connection in addition to the task id if we want to prevent such issue. But on the other side, the task is rollbacked so it can never be executed.