check pageId closely

I don't know how yet, but I managed to get `false` as `pageId` in this
method call. This triggers a very ugly database error. Here is a
replacement with an exception. As a bonus, you get a unit test.