Solves errors with luatex and enables compilation with xetex. Add dedicated test document for the errors with auto-legacy and xe/luatex.