fix small problem and add tests