Reorganizing logic and finishing BitTest.