Fixed appcrash issue. Added new tests