Add term.py and tests