Rewrite randomElement to use randomElements, and add test