Add some missing #[test] attributes.

Ah, this dead code lint is good stuff. :-)
Mark some test-only code as such to avoid dead code warnings.
Update for upstream pkgid changes.
Stop using 'self lifetime (now illegal).