Always use PERSISTENT_STATE mask when persisting task controller state.
When PERSISTENT_STATE mask was not used it was causing Revertibles
to be called twice (because DO_ROLLBACK) flag have been persisted too.
Expose Transaction.isTerminated() method via API.

This method is very convenient because multiple
threads may operate on the transaction. Sample usage:

txn.waitFor(otherTxn);
if (!txn.isTerminated()) {
   // ... do something with txn
}

Of course there's still possibility of check-then-act like race conditions,
but there's at least some way for the thread to check the status of transaction
without registering listener with it (what may fail too if transaction is not in expected state).
rely on AbstractTransactionTest.tearDown() to shutdown executor
Previous solution didn't work because deadlock detection was using
LockSupport.getBlocker() which didn't work as intended. The reason was
the LockSupport.park() was called after deadlock detection finished.
In order to make deadlock detection to work transactions dependency
must be registered first.

Design decisions:
 * if thread calling waitFor() is interrupted, InterruptedException is thrown
 * if any of waitFor() participating transactions is terminated the waitFor() dependency
   is discarded and associated thread will continue in its execution
 * it is allowed for two distinct threads to create the same transaction waitFor() dependency.
   Such redundant dependencies will use separate condition objects (impl. decision due to simplicity).
fixing TransactionImpl finalization