Improve tests and refactor HTML