JCLOUDS-528

apply changes from code review

formatting and structure change
improved unit test to better test all condition.