Refactoring, adding static factory methods, tests