Fix to resolve #946

Please review the fix and let me know if it does good.
note that `expectMessage` does a substring match, so you don't need to put the entire error message. I would rather not hard-code the entire error message in the test because it's unnecessary brittle. Could you just check for a substring like "name cannot consist of multiple path components"? Thanks