Begin refactor of tagging javascript, with tests :sparkles: