fixed some tests and bugs