small refactor: added testing and optargs parsing