Fixes for jira issue ESBJAVA-3068 and ESBJAVA-3069

Fixes for jira issues given in the links,
[1]https://wso2.org/jira/browse/ESBJAVA-3068
[2]https://wso2.org/jira/browse/ESBJAVA-3069