extract method, added tests
extract method, added tests