Grep tests and implementation