Unit test for bugs found

I have created the unit test for some issues found