Add branch macro and use to tidy some tests