Tests for protected attributes, refactor