Integration tests

Initial integration tests and fixes that they uncovered.

Resolves #87. Resolves #69.