Split alloc into source and header, add test.