Add -P argument to always write PID, and fix tests