Add some tests for how names are applied. Fix bug