Bug fixes and test cases added