- probable crash fix

- fixed test application
- refactoring