Fix for AS7-6356

The commit here fixes the issue reported in https://issues.jboss.org/browse/AS7-6356 and also includes a testcase to verify the fix.