Replace constructors with factories and use newer expectation syntax in tests