Move template selection in class, add tests