refactor echo server a little, add simple tests
flush *out* properly
move echo methods into separate func
fix indentation