Fixed and moved bit calculation function to message.js