Refactor parse_command_line interface

Change-Id: I96331570e07b5d69ec062ae581bf74b08b1730f9
Small fixes

Change-Id: I162cc5be8d77dae00867ecfdda84be8ccd998c8b
Some unittests

Change-Id: I68f09dc7c1416aadde1da939cb5a68d2496ca879