Rearranged R code from BridgeNMix to BridgeTestR