part_of_a_transaction creates a context in which we may call functions which require transactions. When it exits, it does not run after-commit callbacks.
At the moment, after-commit callbacks registered during that context are left "dangling" on the transaction, so if it is followed by calling transaction, an error will be raised.
To prevent this, part_of_a_transaction should clear any registered after-commit callbacks when it exits.
Also, similar to transaction, it should fail if any callbacks exist before it is called.