Fix tests to be Python 3 compatible

This commit includes small fixes in the test suite, such as proper
integer division, dealing with difference in iterators.

Partially-implements: blueprint py3k-support
Change-Id: I4140258f564a639697a130a213d8a7733bee7713
Merge "Fix tests to be Python 3 compatible"