Adding tests and improving error cases for parseFlagMappings.