Reverts HA state transitions if one or more state transition listeners fail

This will make the state machine more resilient and a retried event will
be able to succeed.
Adds tests for state rollback in HAMSM
Merge pull request #1631 from digitalstain/2.0-revert-failed-state-transition

2.0 revert failed state transition