Bug fix
Added test cases