Fix possibility to pass zero to rand_nonzero which is not allowed