Library testing and refactoring