fixes issue with error handling
optimization
adds @MirrorsUsed
adds unit tests