Add unit tests

Merging because the unit tests can't be completed until the solver is rewritten (again!). A few bug fixes are in here, and the unit tests for Expression are broken do to a fundamental flaw.