reformated, test added, small bug fixed