Bug fix with test case