Added integration test, refactored main program