Fix str output in test with updated format
Fix refcounting for exception handling