Refactor parseArguments() to enable testing and modularity

Yeah, now I see why they make things this way in the large projects