Add tests & Fix some issues

Fix #3