delete_undef_values function fix bug #20681

This fix the bug #20681 for delete_undef_values.
It also add the spec test to ensure we don't have regressions
on future.