add tests for allocating with segments, pep8 fixes