Fixes

- Fixed bad logic in data handling block.
- Fixed and refactored the test state to be
 more complete and in line with coding standards.