improved test coverage, refactor parameter parsing
Fixes + apache licence