Fix several bugs in parseArguments and add test suite Edit 

Originally https://github.com/joomla/joomla-platform/pull/1851
Fixes some code style issues.