enable CLI tests separate main logic for the better testability

enable CLI tests
separate main logic for the better testability

testMain() fails with StringIndexOutOfBoundsException. need to be reviewed.