Refactored TransactionState into its own class

The state of a transaction can now be tracked in a TransactionState object which is initialized along with every transaction. Makes it easier for ActiveRecord objects to keep track of whether  the transaction each object is associated with has been committed or rolled back.