Some refactoring, tests for non-jquery.