Make client core randomBits and randomBytes more robust

Closes #173 on merge.