Cleanup transaction after each test

In the current tests the @transaction is left open at the end of most of them. That makes tests ordering-dependent and makes the transaction state be undefined in some cases.