Create two new functions, lowering amount of duplicated code

This PR creates two new functions in postprocessing, code that was simply copy
and pasted over and over, find_in_path() and count_matches().
The three last commits is using these functions, replacing the duplicates.