allow memberships to be deleted and added at same time

If you added a new membership to a person then the list of ids passed to
the nin query would include an undefinded entry. As all the membership
id of a person were not undefined this would result in the query
never selecting any documents. We now filter out any undefineds from the
id list to prevent this.

Fixes #600