extract method, added test