finally compiling, passing tests and working almost the way it should