Some improvements and minor fixes to test cases