Fix for #1064 and added tests for setting/getting opacity