refactor, pulled out code from ajax button handlers (prep for unit tests)
basic test coverage on most of client side code