fixed tests and code for working case