Fix bug #16992

Fixed and existing bug in the testsuite and added testcases as requested in https://github.com/mono/mono/pull/850