Don't access dangling pointer

'project' was already deleted at that point
Fix test in combination with GCC 4.9.1 and -O2

Actually we're relying on undefined behavior in the tests, because
accessing `p->foo` is undefined since the lifetime of `p` has already
ended.