Changed test cases and modified some core functions