JBIDE-16422 - Fixing sonar issues in RS (not WS) code

Fixing 'critical' issues plus a bunch of 'major' ones (including reducing cyclomatic complexity in some methods)
Added more unit tests for edge cases (null args in method calls)