Fix incorrect status in HA Agent

The HAStatus was being calclulated incorrectly. This fixes that calculation, 
and adds a test for this calculation