front-end test plus refactor :rage1: