Added tests for entities and controllers, fixed some found issues

This PR comes with some tests for the controller classes and small fixes for problems found in testing.
Changed visibility to improve testability