test refactoring and added bonus code generation methods in DocumentManager