refactor switch layout js and qunit test