Move helper methods to library.py
Fix failing delete test. Fixes #10823