added a test case and code fix to handle it