Avoid for loop by using list comprehension

Avoid an additional loop while iterating the test lists
by using idiomatic list comprehensions instead.