Fix up some pathscrub behavior and add unit tests