Improved fix and test for GRAILS-8727