Cleanup permalink generation

Fix permalink generation to not contain various smells. See verbose description in the last commit in this PR.
I wonder if expectations like this would be better specified within an explicit 'it' block?

We can probably discuss this in slack, but in general I've been trying to have expectations in named blocks so when they fail I can more easily understand what the purpose is. I tend to specify things in my `before` blocks using `allow()`, and use `expect()` in my named it blocks.