LPS-43952 Fixed edge case and added new test cases to detect it