Please look at the tests written for this, they are based on observed behaviours of the built in contacts filtering.