Add unit tests. Refactor internals to allow reusing assertion method for finding matches in an array.