add some tests
fix some minor bugs