Fixed encoder
Slight modification
Added tests for encoder