Fixed line length > 80 lint warnings for context.py and document.py

Refactored 2 files to reduce the number of lint warnings. Most of the
warnings produced was the line length > 80. Besides that, no other
changed were made.