refactor the way the memberships were handled: use a service to create a new membership and to change a role (get rid of the calls to Thread.current)