Add more checks and rewrite the create_tenant and create_router functions