etcdserver/etcdhttp: split out peers and add tests

using defer in a for loop is dangerous.