Fix bug in negative threshold processing, add unit tests for same case