fix bugs / make tests pass