More changes to fix bug 1403410

The globals cli_globals was set in the constructor when the CliGlobals was
being initialzied . This allowed some threads to sneak in and use this
global before it is fully initialized. This was causing unexpected dump at
the time of SQL_EXEC_CreateContext.

This has been fixed.

Also took care of the review comments from the previous check-in. Getting the
unique context id is now made thread safe

Change-Id: I12778c8cfb6e14138ef7349e15e98e2a1741896d