fixed most bugs, two tests still failing