FLOE-196: Added tests for button.js

Refactored some common methods to a testUtils.js file. Also made some changes to button.js based on tests.