Return ErrInFailedTransaction when trying to Commit a failed transaction

This seems nicer to test for, and can perhaps be used for other
operations as well.
Fix Tx.Commit

I managed to introduce a typo here in commit e4ff54f14cd479044e39,
which broke Commit quite badly.  The reason this went unnoticed for
this long was that there used to be no test case for transaction
commit; add one.