FIX SONAR ISSUE NESTED TRY BLOCKS

refactor the code for nested try blocks and rework
based on comments and fix nested loops complexity

Issue-ID: POLICY-976
Change-Id: Ied02b7838b5e4839a4906f79ff37c4fd6afeccfe
Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
9 files changed