Added basic middleware and tests