bug 848238 - fix attachTo existing+BFCache combo

plus a test for it
bug 848238 - perf win with history.length check