Fixes issue where more HA availability messages than necessary were broadcast

Previous attempt in this area left open a bug where for example the master receiving
 a SlaveIsAvailable event would make it broadcast a MasterIsAvailable event again,
 refuelling a loop of such exchanges. This makes sure that the instance's state and
 the incoming transition are examined to decide on what to broadcast.
Introduces tests for the above.