add tests for issue #46
fix issue #46
Merge f1e9137a36a3a131bb38a9c0841a52009952c7a8 into a289a398b2a6f040d7e9713047dade2c51609796