fixed small bug, added some tests