Improve test cases and stability