Fix #874. Check module path is valid before adding it to $searchpath.