Fixed commit/rollback behavior when an exception is thrown