added tests, few corrections