Add detail test and fix json encoding