Fixes #293

Fixes #293: Improved code organization, improved type safety of variables, and improved coercion of variable values into types with given expressions. Added test suite for coercion to cover common cases.
A "nonsense" test added which will cause it to produce None in the case that the type is unknown.