refactored spec to use annonymous class