cylc testing: improve grep function