Adds a bugfix to ensure the toolbar is not undefined

This is a fix for issue #197 with and regression test.