Fixed some code, made tests pass