Several fixes. Adding tests. Refining grunt config.