refactored namespace resolving and added tests