Fix failing captions test

- Use OpaqueKeys exception
- Remove unused imports
- Clean up syntax
- Remove superfluous print statment
Fix failing forked test