Fix test number generation

The last commit (e89f3783) greatly sped up generation of test numbers when
numType=4, but caused the bit density always to be the same when it should be
random. This commit restores the old behavior while still being orders of
magnitude faster.