Firstly to clarify, you do get both bonuses while wielding an axe and a sword, so the cast speed is fully working as expected.
The attack speed is more complicated and one of those numbers is the result of a bug, so I'll go through each individually.
just sword (1.2 attack rate) in main hand gives 34%
The 1.2 attack rate is multiplicative (it's effectively a 20% more attack speed modifier) so combined with the 12% increased attack speed, this results in 34% increased attack speed as you observed. Nothing's wrong here.
same sword in off hand gives 12%
This is caused by a bug where attack rate has no effect if you don't have a mainhand weapon equipped, resulting in the 12% attack speed from the passive being your only attack speed modifier.
dual wielding that same sword gives 34%
When dual wielding the average of the two weapons' attack rates is used, so assuming you were using another sword with 1.2 attack rate in the mainhand, this is just the same calculation as the first example.
just axe (1.05 attack rate) in main hand gives 18%
Again this is the same sort of calculation as the first example, where you have a 5% more attack speed modifier and a 12% increased attack speed modifier combining for 18% increased attack speed.
and axe + sword gives 40%
Because you had one weapon with an attack rate of 1.05 and one with an attack rate of 1.2 you have an effective attack rate of the average of those two numbers, 1.125. This is effectively a 12.5% more attack speed modifier. Meanwhile you gain a 12% increased attack speed bonus for wielding an axe, and another for wielding a sword for a total of 24% increased attack speed. Combining these modifiers results in 40% increased attack speed as observed.
So it's just the second example, the one where you have no mainhand weapon, that's bugged. A fix for this bug will be included in 0.8.2.