reduce memory allocation && add more testcase