Fixed few issues for CLOUDSTACK-6316,CLOUDSTACK-5674

Fixed issues related to the mentioned bugs.
More information in the bug.

Signed-off-by: Santhosh Edukulla <Santhosh.Edukulla@citrix.com>
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>