Refactored tests, extracted some helpers