refactor and add specs for tag namespaces.