Fix random_int() based on @jedisct1's suggestions