Restructuring option parsing and adding unit tests.