Transaction failure should not leave the protocol in a faulty state

Previously, if a transaction failed, the protocol thought it was inside a transaction while the server knew it was not. This state mismatch rendered the protocol instance unusable.

This patch just fixes the state mismatch, so the protocol and the server agree after a transaction failure.