refs #57 some refactorings to have better testable code, loads of tests and bugfixes
Merge branch 'master' of github.com:piwik/piwik