refactored lib/messages and lib/utils

simplified messages.addMessage() a bit

minimized messages.extractDetails(), return the objects and use dot
notation in the templates instead of these random keys.

replace | with
{{contact_name}} {{contact.name}}
{{chw_phone}} {{contact.phone}}