Fixed a small bug and completed the tests