Unit test hardening
Improve image reference handling