randx: fix a bug, more thorough validation