Add tests to Apiaries controller + bug fixes