Fix up API tests to handle 2-to-3 conversion.

This change makes a couple changes to the API interface tests. The first is a
change to use six.iteritems when iterating over a dict (since Python 3.x
doesn't have an iteritems() method on dict itself). The second fixes the type
that we're passing into setlocale() to make it work correctly with both Python
2.x and 3.x.

Testing done:
Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6674/