fixed all broken unit tests and fixed some slight api bugs