Reindent for clarity
Adding test capturing #116
Moved imports to the top, made them compatible with Python 2, and added a docstring.
Corrected a TypeError when reading a local package index on Python 3. Fixes #116.