Made tests compatible with Python 3

- Use range instead of xrange (no too much data anyway, so no performance problem
- UTF-8-decode response data