Fix query and aggregation of role implications

* Collate roles and contexts to issue a single query for all
  RoleImplication objects
* Fix aggregation of roles and contexts to handle the case where a user
  has one role in multiple contexts