remove code duplication for checking sanity check paths, refactor to stop hardcoding 'files' and 'dirs' here and there