Fixes quorum check in ElectionState

The quorum check was wrong, leading to instances proceeding to do elections
 even when there were not enough instances left in the cluster, showing
 symptoms of split brain. This adds some tests and a fix for the issue
Fixes and reenables ElectionStateTest.testElectionFromDemoteIsRejectedIfNoQuorum