Additional code refactoring and coverage