updated sonnet.py and tests.py from sonnet