added some corrections and tests