Added membership checks.
Refactored test.
follow up fix to the pull request #28