Algebraic tests

Utility. Next up, actual tests using it.