Now returns results properly ordered + Proper unit test + Refactoring

Moved commented out testing code to a testing file
Added a test method that nose picks up and runs
Run nosetests (install nose to python if you haven't)

Made the results actually be the results, they are now ordered according
to the method described on the wiki.

Made the code a bit more pythonic, used ordereddict and defaultdict
where applicable.