some more refactoring; fix test error