fixed tests and implementation