Added missing assert

Added missing assert in the test case and refactored private method to avoid repetition.