added tests and fixed bug in grep