PEP8 and other clean up of test code

Mostly I fixed PEP8 things, but I also made it so some tests that were
repeatedly calling assert_equal or asser_raises in a for loop now use
yield statements, so we can see what the results for all the different
arguments are.