Integration tests

This is in-progress pull request. It will be merged when it's ready.

Anyone interested in developing integration tests, please PR against this branch.