fixed and added some tests