added some test cases for checking the functionality; also fixed some bugs found through it