Refactor context.py. Add BaseContext super class to reduce duplication