Modularize open and assert functions