fixed bug in search
added tests