move the election handling to a separate class, for testing
update to use new communication interface