Use iterators for scanning members vector in order to avoid issues with integer signedness and range checks. The vector is usually rather small and not in hot codepath, so performance is here not an issue. Added unit test for member_index() method.