refactored and fixed tests to work again