Factor out check for valid --parent-pid and add tests.