Added: tests for logic
Fix: issues in code