write tests and extract watch functionality

also fix a bug in BufferedLogger's Write()