Wrote some tests and found some errors.