Added tests and fixed many errors.