removed unused code
fix some bugs and increase coverage