fix bugs in core api
unit test of core api