Improved error handling and added tests related to ComplexAlarm.

* See https://github.com/ypid/ComplexAlarm