added some tests, fixed a small bug