LPS-33511 NPE bug fix + tests