REL-1596: Fixed bugs as per testing and modified test cases to test new features.

Also fixed bug in existing test cases for NIRI that was causing failure due to NullPointerException.