Updated unit-tests and fixed some bugs they found.