fixed tests and bugs.