added integration test with complete go program and fixed a problem with inserting a semicolon at the end of file if necessary.