Catch more ha agent policy thread errors.

Fixes OOIION-675, and adds a test for it
Merge pull request #496 from oldpatricka/OOIION-675

Catch more ha agent policy thread errors.