add tests
fix minor bugs