#UDPATE: fix issue and add some test cases.