Add test cases and change API interfaces