test all and when method