improved tests and avoid scanning if known to not contain val