Tests and modifications as in master branch. Changed to using .attr() for setting selected.