factor out implementations
fix tests
cleanup protocols