added tests & fixes