Move resource detection to separate class + tests