[TRUNK-4030] added some testcases and resolved issues with my previous commit