Refactor find_matches for testing