fixed bugs and add some tests
fixed bugs
fixed bugs
fixed bugs
fixed bugs