Fix infinite loop on duplicate keysalt types

(when duplicate suppression is requested, which is always for in-tree callers.)

Add some tests to try and cover dupe suppression a bit.