Added tests for the allocator and cleaned up the logic

Summary: Added tests for the allocator

Test Plan: go test ./...

Reviewers: spencerkimball

Reviewed By: spencerkimball

Differential Revision: http://phabricator.andybons.com/D37