fix a small bug and add a basic test