Add tests for Trac #16221 and #16342