refactoring some code in the strstr/regexp/nandsim tests