Issue #31: integration tests and refactoring