Cleanup permalink generation

Fix permalink generation to not contain various smells. See verbose description in the last commit in this PR.
I typically prefer to specify the primary result explicitly and accept implementation detail mocks in a `before` block. Without adding an explicit `it` block for them.

This would be different if the call of an external mocked interface would cause a sideffectful state transition, which is not the case here.

I'm fine to stick to your preference here BTW.