Fix wrong assertions

Close #396.