Improving test and search logic