Add type checking for module arguments, converting as much as possible

Converts to list from comma-separated strings, and to dicts from comma-separated, key=value strings.

Fixes #2126.