Fix bin id types and add test coverage.