Added some tests and fix #16 issue