added some more tests which found some bug, fixed bug