Refactoring, adding unit tests for extract_routing_prefix