Replace commonprefix() with commonpath() to correctly find common dirs

Replace commonprefix() with commonpath() to correctly find common dirs.
Currently commonprefix() returns nonsensical paths (as the documenation
warns). commonpath() instead returns only real directories. This fixes #52