Measurements of mean lifetime and branching fractions of b hadrons decaying to J/ψ