fix bin data types and add tests to ensure bin data type gets persisted to mongodb properly.