removed unused imports, thanks pyflakes
added tests for rg
fixed more pyflakes warnings