fixing non-compiling code and failing tests