Fix for #48

Rework of how services are sorted based on dependencies using a topological sort approach. 
Added tests for sort_service_dicts().

Let me know if this looks OK, or if more comments/tests are necessary!