polishing and tests refactoring