Add partial test suite (work in progress).
Fix silly bugs.