Refactor isLibrary test function