Fix a few broken tests.
Fix some broken tests for Python 3.
Work around missing cmp() function in Python 3.
Cast maps to explicit lists.