Extract the pickRandom function, test it