Stop using more deprecated test methods.
Use for loop instead of map.
NEWS entry for python3 changes.
Ensure that we close all files. Add close methods to appropriate classes, and
make classes that have close methods in to context managers, so that they can be
used with `with` statments.