Allow objects that implement to_str or to_path to singleton methods, and add corresponding tests.