more robust hash generation, and hash testing