Fix incorrect number of matches reported for 'list -p <pattern>'

When listing only items matching a pattern, only include matched
items in the count at the end of the output.

In the CLI test, use new key agent, clipboard and console IO fakes
for each test to avoid possible reliance on test ordering.