Use Kernel::rand
Refactoring of spec test