added some tests and fixed small bugs