Added a test and change api to fix #18