updated with "test" flag, comments and small output changes