Added: tests for abs and app terms plus some refactoring