The necessity of randomness in tests of Bell inequalities