Fix and Unit Test for PIG-3833