refactor python

Merged _helper.py into centroid.py, add tests, fixed an edge case, and
improved code.
config to string json
tabs => spaces