refactoring of managing command-line options + unit-tests