Registry refactoring and tests