Refactor common behavior of Api and Namespace to NamespaceBehavior trait