some improvements and more tests