refactored, more tests