move option parsing to its own method so it can be tested