Refactor todo controller to serialize JSON properly (fixes #2)