Some bug fixes
Added Unittest
Added API