improved bern_bin function to work with additional factors.

Also now calls beta_cis in one step.