improvements and more tests