Fix certificate exchange and add invitation token support

This patch fixes some bugs in the refactoring and adds support for
certificate exchange through tokens, in line with PZH WS changes.

Jira issue: WP-852
Merge pull request #15 from jplyle/support-invitation-tokens

Fix certificate exchange and add invitation token support