fix #9673.
fix #9711.
added test for #9711.