Fixed some bugs for SearchCommand.
Write tests for SerachCommand.