add some tests and fix some gui bugs