Factor pin stuff to lib/pin.js

General rule: 'util.verbFoo()' is less ideal than 'foo.verb()',
especially once there is more than one verb to be done with foo.

This sets the stage for a proper db refactoring, so that tests can
be more guaranteed to not clobber the "real" db.

Fix #68