Add structure to tests by using contexts.

Some tests are having a bunch of test methods that have the same
context. These methods are now part of inner classes.