some improvements, added couple of tests
some improvements, added couple of tests