Changes some functions and add test.