Wrote unit tests for ERAT and fixed some bugs that were found becasue of it.