added tests
Various fixes