EZP-23553: Fix checking for existence of legacy templates