fix bugs
fix bugs and test