Add tests and refactor to improve cli-parser testability.
Fix leaves script and cli-parser.
Simplify cli-parser.
Add license.