More testcases and minor changes in code