watch_directories(): only add a trailing '/' to directory_key if it is not empty; add test