Fix tests and add integration test.