add tests for utils
refactor flatten_object util
add more tests