A circuit comprises: scan chains comprising scan cells, the scan chains configured to shift in test patterns, apply the test patterns to the circuit, capture test responses of the circuit, and shift out the test responses; a decompressor configured to decompress compressed test patterns into the test patterns; and a
test response compactor configured to compact the test responses, the
test response compactor comprising: first X-masking circuitry configured to
mask, based on first masking information, some of X bits in the test responses, the first masking information remaining the same while a
test response for each of the test patterns is being shifted out, the first masking information being different for at least two of the test patterns; and second masking circuitry configured to
mask, based on second masking information, rest of the X bits in the test responses.