refactor and tests for type_apartment service