test cases and minor fixes